<%--
  Created by IntelliJ IDEA.
  User: 小玄
  Date: 2022.08.13
  Time: 16:20
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"  %>
<%@ include file="common.jsp"%>
<html>
<head>
    <title>主页面</title>
    <link rel="shortcut icon" href="#"/>
</head>
<body>
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo layui-hide-xs layui-bg-black">九组后台管理系统v1.0</div>
        <!-- 头部区域（可配合layui 已有的水平导航） -->

        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item layui-hide layui-show-md-inline-block">
                <a href="javascript:;">
                    <img src="${user.avatar}" class="layui-nav-img">
                    ${user.username}
                </a>
                <dl class="layui-nav-child">
                    <dd><a href="">功能待定</a></dd>
                    <dd><a href="${pageContext.request.contextPath}/login/logout.do">退出</a></dd>
                </dl>
            </li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll" >
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree" lay-filter="test" >
                <c:forEach items="${menuListMap.firstMenuList}" var="menu">
                    <li class="layui-nav-item  ">
<%--                        <a class="" href="javascript:;">${menu.menuName}</a>--%>
                        <a class="" href="javascript:;"><i class="${menu.icon}"></i>&nbsp<span>${menu.menuName}</span></a>
                        <c:forEach  items="${menuListMap.secondMenuList}" var="subMenu">
                            <%--判断子菜单是否属于当前父菜单--%>
                            <c:if test="${subMenu.parentId eq menu.menuId}">
                                <dl class="layui-nav-child">
                                    <dd id="hreftosrc"><a href="${subMenu.url}">${subMenu.menuName}</a></dd>
                                </dl>
                            </c:if>
                        </c:forEach>
                    </li>
                </c:forEach>
            </ul>
            <script>
                /*当点击一个一级菜单时关闭其他的一级菜单*/
                $(".layui-side").on("click", ".layui-nav-item", function(){
                    $(this).siblings('li').attr('class','layui-nav-item');
                });
            </script>
        </div>
    </div>

    <div class="layui-body">
        <!-- 内容主体区域 -->
        <iframe src="hello.jsp" id="main" width="100%" style="height: 99.9%" frameborder="0"></iframe>
<%--        <iframe id="main" width="100%" height="100%" src="hello.jsp"></iframe>--%>
    </div>

    <div class="layui-footer">
        <!-- 底部固定区域 -->
       UwU
        <a href="front/testLogin.jsp" 	class="layui-btn layui-btn-normal">去测试者登录页面</a>
    </div>
</div>
<script>
    //JS
    layui.use(['element', 'layer', 'util','jquery'], function(){
        var element = layui.element
            ,$=layui.jquery
            ,layer = layui.layer
            ,util = layui.util;

        //头部事件
        util.event('lay-header-event', {
            //左侧菜单事件
            menuLeft: function(othis){
                layer.msg('展开左侧菜单的操作', {icon: 0});
            }
        });

        $(document).ready(function(){
            $("dd#hreftosrc>a").click(function (e) {
                e.preventDefault();//取消事件的默认动作。
                $("#main").attr("src",$(this).attr("href"));
            });
        });


    });
</script>
</body>
</html>
